<?php

namespace App\Repositories;

use App\Models\Announcement;
use InfyOm\Generator\Common\BaseRepository as iBaseRepository;

class AnnouncementRepository extends iBaseRepository
{
    /**
     * @var array
     */
    protected $fieldSearchable = [
        'title',
        'cover',
        'content',
        'status'
    ];

    /**
     * Configure the Model
     **/
    public function model()
    {
        return Announcement::class;
    }

    public function findWithoutFail($id, $columns = ['*'])
    {
        try {
            $house = $this->find($id, $columns);
            if ($house)
            {
                $house->cover_path = $house->cover;
                $house->cover = fileUrl($house->cover);
            }

            return $house;
        } catch (\Exception $e) {
            return;
        }
    }
}
